package com.library.servlet.student;

import com.library.service.student.RankService;
import com.library.servlet.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/student/rank/*")
public class RankServlet extends BaseServlet {
    private RankService rankService = new RankService();

    // 学生借书排行榜
    protected void borrowRank(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setAttribute("rankList", rankService.getBorrowRank());
        req.getRequestDispatcher("/WEB-INF/student/rankBorrow.jsp").forward(req, resp);
    }

    // 书籍热度排行榜
    protected void bookHotRank(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setAttribute("bookRankList", rankService.getBookHotRank());
        req.getRequestDispatcher("/WEB-INF/student/rankBook.jsp").forward(req, resp);
    }
} 